/* ----------------------------------------------------------------------
 *	Shadow Quest
 *	Copyright (C) 2009 Prageeth Silva <prageeth@thenewcoders.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *  ----------------------------------------------------------------------
 */

package menu.tabobject;

import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;

import sq.RPG;
import sq.FontLoader;

/** Object to be placed in a MenuTab
 * 
 */
public class MenuTabLabel extends MenuTabObject
{

	private String text;
	
	public MenuTabLabel(String text, float x, float y, Alignment alignemnt, Color color)
	{

		super(x,y,alignemnt,color);
		this.setText(text);

	}
	
	public MenuTabLabel(String text, float x, float y, Alignment alignemnt)
	{

		this(text,x,y,alignemnt,Color.black);

	}
	
	public MenuTabLabel(String text, float x, float y)
	{

		this(text,x,y,Alignment.LEFT);

	}

	public String getText()
	{
		return this.text;
	}

	public void setText(String text)
	{
		this.text = text;
	}
	
	/** Update the game state for a frame.
     * @param input The input object
     * @param delta Time passed since last frame (milliseconds).
     */
	@Override
	public void update(Input input, int delta)
    throws SlickException
    {
    	// do nothing
    }
    
    /** Render the entire screen, so it reflects the current game state.
     * @param g The Slick graphics object, used for drawing.
     */
    @Override
	public void render(Graphics g)
    throws SlickException
    {
    	
    	g.setColor(this.getColor());
    	g.setFont(FontLoader.getFontSize12());
    	if (this.getAlignment() == Alignment.RIGHT) {
    		int width = g.getFont().getWidth(this.getText());
    		g.drawString(this.getText(), this.getX()-width, this.getY());
    	} else if (this.getAlignment() == Alignment.CENTER) {
    		int width = g.getFont().getWidth(this.getText());
    		g.drawString(this.getText(), (RPG.getScreenWidth()-width)/2, this.getY());
    	} else {
    		g.drawString(this.getText(), this.getX(), this.getY());
    	}

    }

	@Override
	public void resetValue() {
		// do nothing
	}

	@Override
	public void saveValue()
	{
		// do nothing
	}
	
}
